package pub.developers.forum.infrastructure.dal.dao;

import org.apache.ibatis.annotations.Param;
import pub.developers.forum.api.model.PageRequestModel;
import pub.developers.forum.api.response.data.LastMonthData;
import pub.developers.forum.domain.entity.value.PostsPageQueryValue;
import pub.developers.forum.infrastructure.dal.dataobject.PostsDO;

import java.util.Date;
import java.util.List;
import java.util.Set;


public interface PostsDAO {

    void deleteByAuthorId(@Param("author_id") Long authorId);
    void insert(PostsDO postsDO);

    List<PostsDO> query(PostsDO postsDO);

    List<PostsDO> queryByValue(PostsPageQueryValue pageQueryValue);

    List<PostsDO> getAllPost ();

   Long[] getFilterPosts(PageRequestModel pageRequestModel);


   //获取分页查询时,被过滤的帖子的总数
   Long getFilterTotal(PageRequestModel pageRequestModel);

    void update(PostsDO postsDO);

    PostsDO get(Long id);

    void increaseComments(@Param("id") Long id, @Param("updateAt") Date updateAt);

    void decreaseComments(@Param("id") Long id, @Param("updateAt") Date updateAt);

    void increaseViews(@Param("id") Long id, @Param("updateAt") Date updateAt);

    List<PostsDO> queryOrderViews(@Param("category") String category, @Param("auditState") String auditState);

    List<PostsDO> queryInIds(@Param("ids") Set<Long> ids);

    List<PostsDO> queryInIdsAndState(@Param("ids") Set<Long> ids, @Param("auditState") String auditState);

    void delete(Long id);

    void softDelete(@Param("id") Long id,@Param("update") Date update);

    void increaseApproval(@Param("id") Long id, @Param("updateAt") Date updateAt);

    void decreaseApproval(@Param("id") Long id, @Param("updateAt") Date updateAt);

    List<Long> getAllIdByAuthorId(@Param("authorId") Long authorId, @Param("auditState") String auditState);

    //根据用户id拿到用户发表的帖子的id
    Long[] getPostsIdByUserid(Long id);

    Long[] getPostsIdByUseridAndPage(@Param("id") Long id,PageRequestModel pageRequestModel);
    Long[] getPostsId(PageRequestModel pageRequestModel);

    Long[] getReportedPostsId(PageRequestModel pageRequestModel);

    Long[] getBanPostsId(PageRequestModel pageRequestModel);

    //根据帖子id 拿到对应的帖子信息
    PostsDO selectPostById(Long postId);

    //昨日新增帖子数
    Long selectNewPosts(@Param("today") String today , @Param("yesterday") String yesterday);

    //进一个月的新增帖子数
    List<LastMonthData> selectMonthData(@Param("lastMonthDay") String monthDay , @Param("today") String today);

    //查询官方帖子
    List<PostsDO> queryOfficial();
}
